import Vue from 'vue'
import VueRouter from 'vue-router'
// import Home from '../views/Home.vue'

import User from '../views/User.vue'

import Book from '../views/Book.vue'
import Blog from '../views/Blog.vue'
import Video from '../views/Video.vue'
import TestBlog from '../views/TestBlog.vue'
// import AddBlog from '../views/AddBlog.vue'
import Resources from '../views/Resources.vue'
import Map from '../views/map/map.vue'
// import Home from '../views/home/index.vue'
import Index from '../views/index.vue'
import Mall from '../views/mall/index.vue'
import Page1 from '../views/other/page1.vue'
import Page2 from '../views/other/page2.vue'
import Home from '../views/Home.vue'

// 文本编辑器
import mavonEditor from 'mavon-editor'
import 'mavon-editor/dist/css/index.css'
Vue.use(VueRouter)
Vue.use(mavonEditor)
const routes = [
  {
    path: '/',
    name: 'Index',
    redirect:'/home',
    component: Index,
    children: [
      {
        path: '/book',
        name: '',
        component: Book
      },
      {
        path: '/home',
        name: '',
        component: Home
      },

      {
        path: '/blog',
        name: '',
        component: Blog
      },
      {
        path: '/video',
        name: '',
        component: Video
      },
      {
        path: '/testblog',
        name: '',
        component: TestBlog
      },
      {
        path: '/resources',
        name: '',
        component: Resources
      },
      {
        path: '/map',
        name: '',
        component: Map
      },
      {
        path: '/user',
        name: 'User',
        component: User
      },
      {
        path: '/mall',
        name: 'mall',
        component: Mall
      },
      {
        path: '/page1',
        name: 'page1',
        component: Page1
      },
      {
        path: '/page2',
        name: 'page2',
        component: Page2
      },
    ]
  },

]
new Vue({
  'el': '#main',
  data() {
    return { value: '' }
  }
})

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})


// router.beforeEach((to,from,next) => {
//   if(to.path == '/user'){
//     next();
//   }else{
//     if(localStorage.getItem("token")){
//       next();
//     }else{
//       next("/user")
//     }
//   }
// })

export default router
